import {request, handleFetchResultNotification, REQUEST_TYPE} from '../utils';
import stringify from 'Shared/utils/stringify';
import {formatMessage} from './intl';

const baseUrl = '/afterSales/api/v1';
const resourceName = formatMessage({
    id: 'api.resourceName',
    defaultMessage: '索赔结算报表'
});
const getListDq = formatMessage({
    id: 'api.message.getList',
    defaultMessage: '查询大区数据'
});
const getListDesc = formatMessage({
    id: 'api.message.getListDesc',
    defaultMessage: '查询{resourceName}'
}, {resourceName});

// 索赔费用报表(1)-不同比不环比
export const getSettlementCost = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/settlementCost?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};

// 索赔费用报表(1)-勾选同比
export const getSettlementCostYear = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/settlementCost/yearOnYear?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};

// 索赔费用报表(1)-勾选环比
export const getSettlementCostLink = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/settlementCost/linkRatio?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};

// 结算周期报表(2)-不同比不环比
export const getSettlementCycle = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/billingCycle?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};
// 结算周期报表(2)-勾选同比
export const getSettlementCycleYear = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/billingCycle/yearOnYear?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};
// 结算周期报表(2)-勾选环比
export const getSettlementCycleLink = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/billingCycle/linkRatio?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};
//索赔费用报表-审核者(3)
export const getSettlementReject = pageOption => {
    const queryString = stringify(pageOption);
    return request(`${baseUrl}/claimReportSettlement/rejectTrue?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDesc));
};
// 查询大区数据列表
export const getList = condition => {
    const queryString = stringify(condition);
    return request(`${baseUrl}/marketDepartments?${queryString}`, null, null)
        .then(handleFetchResultNotification(REQUEST_TYPE.query, getListDq));
};
